package cn.edu.sasu.http;

import java.util.Properties;

import android.util.Log;
import cn.edu.sasu.utils.PropUtil;

public class HttpUrl {
	private HttpUrl() {
	};

	// 构造url
	public static final String URL = "http://" + PropUtil.getProp("host") + ":"
			+ PropUtil.getProp("port") + "/" + PropUtil.getProp("project")
			+ "/";
	// public static final String URL
	// ="http://223.86.123.40:8080/sasuNewsServer/";
	private static final String ACTION = ".action";

	private static Properties pp = new Properties();
	static {
		try {
			pp.load(HttpUrl.class.getResourceAsStream("category.properties"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// 校园新闻
	public static final String URL_NEWS_SCHOOLNEWS = pp
			.getProperty("URL_NEWS_SCHOOLNEWS");// "校园新闻";
	// 通知公告
	public static final String URL_NEWS_NOTICE = pp
			.getProperty("URL_NEWS_NOTICE");// "通知公告";
	// 文理广场
	public static final String URL_NEWS_MAIDAN = pp
			.getProperty("URL_NEWS_MAIDAN");// "文理广场";
	// 合作交流
	public static final String URL_NEWS_COOPERATECOMMUNION = pp
			.getProperty("URL_NEWS_COOPERATECOMMUNION");// "合作交流";
	// 学院概括
	public static final String URL_NEWS_BASICFACTS = pp
			.getProperty("URL_NEWS_BASICFACTS");// "学院概括";

	// 综合服务
	public static final String URL_NEWS_INTEGRATEDSERVICE = pp
			.getProperty("URL_NEWS_INTEGRATEDSERVICE");// "综合服务";
	// 学术动态
	public static final String URL_NEWS_ACADEMICTRENDS = pp
			.getProperty("URL_NEWS_ACADEMICTRENDS");// "学术动态";
	// 创先争优
	public static final String URL_NEWS_BEFOREEXCELLENT = pp
			.getProperty("URL_NEWS_BEFOREEXCELLENT");// "创先争优";
	// 中国梦
	public static final String URL_NEWS_CHINADREAM = pp
			.getProperty("URL_NEWS_CHINADREAM");// "中国梦";
	// 群众路线
	public static final String URL_NEWS_MASSLINE = pp
			.getProperty("URL_NEWS_MASSLINE");// "群众路线";

	// 文理话题
	public static final String URL_TOPIC = pp.getProperty("URL_TOPIC");// "话题";
	// 文理图片
	public static final String URL_PICTURE = pp.getProperty("URL_PICTURE");// "图片";
	// 文理跟帖
	public static final String URL_FOLLOW = pp.getProperty("URL_FOLLOW");// "跟帖";
	// 文理投票
	public static final String URL_VOTE = pp.getProperty("URL_VOTE");// "投票";

	// 新闻
	private static final String NEWS = "android/newsClientAction!"; // new：表示的是struts2的包名。newsClientAction：表示的是Action的名
	public static final String NEWS_SELECT = NEWS + "selectNews";// selectnews:表示的是调用具体的方法
	public static final String NEWS_LOAD = NEWS + "selectNewsDetail";
	public static final String NEWS_COMMENTS = NEWS + "selectNewsComments";
	public static final String NEWS_PIC = NEWS + "selectNewsResource";
	// 评论
	private static final String COMMENTS = "android/commentsClientAction!";
	public static final String COMMENTS_SELECT = COMMENTS + "selectComments";
	public static final String COMMENTS_ADD = COMMENTS + "addComment";

	// 用户的请求地址
	private static final String USER = "android/userClientAction!";
	public static final String USER_LOGIN = USER + "login";
	public static final String USER_REGISTER = USER + "register";
	public static final String USER_COLLECT = USER + "addCollect";

	/**
	 * 是否启动调试
	 */
	private static final boolean debug = true;
	private static final String TAG = "debug_sasu";

	// 拼接地址
	public static String url(String method) {
		StringBuffer buffer = new StringBuffer(URL);
		buffer.append(method);
		buffer.append(ACTION);
		String path = buffer.toString();
		if (debug)
			Log.i(TAG, ">>>>>>>> " + path);
		return path;
	}
}
